using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Attacking : MonoBehaviour
{
    public float knockbackForce;
    public int attackPower;

    private void OnTriggerEnter2D(Collider2D collider)
    {
        IDamageablePlayer damageable = collider.GetComponent<IDamageablePlayer>();
        if (damageable != null)
        {
            Vector3 _position = transform.parent.position;
            Vector2 direction = collider.transform.position - _position;


            damageable.OnHitP(attackPower, direction * knockbackForce);
        }
    }
}

